<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="Thymeleaf">
<head>
    <meta charset="utf-8">
    <title>品牌信息修改</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../css/oksub.css" >
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <!--<script type="text/javascript" src="../../lib/loading/okLoading.js"></script>-->
</head>
<body class="ok-body">
<div class="layui-row">
    <div class="layui-col-xs12 layui-col-md-offset1 layui-col-sm12 layui-col-md6">
        <form class="layui-form layui-form-pane ok-form">
            <div class="layui-form-item">
                <label class="layui-form-label">品牌id<span style="color:red">*</span></label>
                <div class="layui-input-block">
                    <input class=" layui-input" placeholder="品牌id设置不可修改" autocomplete="off" name="ndiagnosis" lay-verify="numberPlus"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">品牌名<span style="color:red">*</span></label>

                <div class="layui-input-block">
                    <input class=" layui-input" placeholder="修改品牌名" autocomplete="off" name="ndiagnosis" lay-verify="numberPlus"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">品牌logo地址<span style="color:red">*</span></label>

                <div class="layui-input-block">
                    <input class=" layui-input" placeholder="修改品牌logo地址" autocomplete="off" name="ndiagnosis" lay-verify="numberPlus"/>
                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">介绍<span style="color:red">*</span></label>

                <div class="layui-input-block">
                    <input class=" layui-input" placeholder="修改品牌介绍" autocomplete="off" name="ndiagnosis" lay-verify="numberPlus"/>
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">显示状态<span style="color:red">*</span></label>

                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="open" lay-skin="switch" lay-text="显示|隐藏" lay-filter="switchTest" title="开关">
                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">检索首字母<span style="color:red">*</span></label>

                <div class="layui-input-block">
                    <input class=" layui-input" placeholder="修改品牌检索首字母" autocomplete="off"  name="ndeath" lay-verify="numberPlus"/>
                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序<span style="color:red">*</span></label>

                <div class="layui-input-block">
                    <input class=" layui-input" placeholder="修改品牌排序" autocomplete="off" name="ncure" lay-verify="numberPlus"/>
                </div>

            </div>
            <div class="layui-form-item" style="text-align: center">
                <div class="layui-input-block" style="margin-left: 0">
                    <button class="layui-btn" lay-submit lay-filter="edit">确认修改</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>

</body>
<script src="../../lib/layui-v2.5.5/layui.js"></script>
<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<!--<script src="../static/js/allAjax.js"th:src="@{/js/allAjax.js}"></script>-->
<script>
    layui.use(["element", "form", "laydate", "layer","okLayer", "okUtils", "jquery", "okLayx"], function () {
        let form = layui.form;
        let laydate = layui.laydate;
        let layer = layui.layer;
        let okLayer = layui.okLayer;
        let okUtils = layui.okUtils;
        let okLayx = layui.okLayx;
        let $ = layui.jquery;
        okLoading.close();
        function setCity(parentid)
        {
            $("#city").children().remove();

            $.ajax({
                url: "/findcity",
                data:{parentid:parentid},//数据为具体省名，例如广东省
                type: "post",
                dataType: "json",
                success: function (data) {
                    if(data["code"]==0)
                    {
                        var hasCity=false;
                        $.each(data["data"],function (index , value) {
                            hasCity=true;
                            $("#city").append("<option value="+value["id"]+">"+value["city"]+"</option>");
                        })
                        if(!hasCity)
                        {
                            $("#city").append("<option value=''>无</option>");
                        }
                        form.render();
                    }
                }
            });
        }
        form.verify({
            numberPlus: function (value, item) {
                var re =  /^[0-9]\d*$/;

                if (!new RegExp(re).test(value)) {
                    return '只能填写整数';
                }
            }
        });

        //------------5.确认添加，后台插入到数据库的连接,省市id放入province city，city可能为''
        form.on("submit(edit)", function (data,index) {
            layer.msg("修改成功",{anim:0,time:1500},function () {
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            });
            // $.ajax({
            //     url: "/Epdataadd",
            //     data: data.field,
            //     type: "post",
            //     dataType: "json",
            //     success: function (data) {
            //
            //         if (data["code"] === 0) {
            //             $("select,input,textarea,button").addClass("layui-disabled");
            //             form.render();
            //             okLayx.notice({
            //                 title: "成功",
            //                 type: "success",
            //                 message: data["msg"]
            //             });
            //             setTimeout(function () {
            //                 parent.layer.close(parent.layer.getFrameIndex(window.name))
            //             }, 3000);
            //
            //
            //         } else if (data["code"] === 300)
            //             okLayx.notice({
            //                 title: "错误",
            //                 type: "error",
            //                 message: data["msg"]
            //             });
            //         else
            //             okLayx.notice({
            //                 title: "异常",
            //                 type: "error",
            //                 message: data["msg"]
            //             });
            //     }
            // });
            return false;
        });

    });

</script>
</html>